<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
const worker = 'resources/shadowrealm-promise-rejection-test-worker.js';

promise_test(async (t) => {
  assert_not_equals(
              self.ShadowRealm, undefined,
              'ShadowRealm should be defined.');
  const scope = 'resources/';
  const reg = await service_worker_unregister_and_register(t, worker, scope);
  await wait_for_state(t, reg.installing, 'activated');
  await reg.unregister();
}, 'Promise rejections within worker thread ShadowRealms are handled');

</script>
</body>
</html>
